#include<bits/stdc++.h>
using namespace std;
int main(){
vector<long long> v;
long long x;
for(int i = 0; i < 3; i++){
cin>>x;
v.push_back(x);
}
sort(v.begin(),v.end());
if(v[1]== v[0] && v[1] == v[2]) cout<<0;
else if(v[2] - v[1] == 1 && v[2] - v[0] == 1) cout<<0;
else if(v[0] - v[2] == 1 && v[1] - v[2] == 1) cout<<0;
else{
if(v[2] == v[1]) cout<<v[2] -1 - v[0];
else cout<<(v[2] - 1)*2 - v[1] - v[0];
}
}
1478A - Nezzar and Colorful Balls | 1581B - Diameter of Graph |
404A - Valera and X | 908A - New Year and Counting Cards |
146A - Lucky Ticket | 1594C - Make Them Equal |
1676A - Lucky | 1700B - Palindromic Numbers |
702C - Cellular Network | 1672C - Unequal Array |
1706C - Qpwoeirut And The City | 1697A - Parkway Walk |
1505B - DMCA | 478B - Random Teams |
1705C - Mark and His Unfinished Essay | 1401C - Mere Array |
1613B - Absent Remainder | 1536B - Prinzessin der Verurteilung |
1699B - Almost Ternary Matrix | 1545A - AquaMoon and Strange Sort |
538B - Quasi Binary | 424A - Squats |
1703A - YES or YES | 494A - Treasure |
48B - Land Lot | 835A - Key races |
1622C - Set or Decrease | 1682A - Palindromic Indices |
903C - Boxes Packing | 887A - Div 64 |